
import Instance from '@/utils/http.ts';

const WHl_BASE=`/warehouseLayout/`;

// 分页获取所有的分隔数据
export function useGetAllByPageAPI(current:number,pageSize:number){
    return Instance({
        url:WHl_BASE+`getAllByPage`,
        method:'GET',
        params: {current: current, pageSize: pageSize}
    })
}

// 新增一条数据
export function useAddOneAPI(warehouseLayout:{}) {
    return Instance({
            url:WHl_BASE+`saveOne`,
            method: 'POST',
            data:warehouseLayout
        }
    )
}

// 根据id获取一条信息
export function useGetByIdAPI(id:number) {
    return Instance({
            url:WHl_BASE+ "getById/"+`${id}`,
            method: 'GET',
        }
    )
}

//根据父id获取数据
export function useGetSecondLevelByPidAPI(pid:number) {
    return Instance({
            url:WHl_BASE+ `getSecondLevelByPid`,
            method: 'GET',
            params:{
                pid
            }
        }
    )
}

// 根据id删除数据
export function useDeleteByIdAPI(id:number) {
    return Instance({
            url:WHl_BASE+ `deleteById/${id}`,
            method: 'DELETE',
        }
    )
}

// 修改数据
export function useUpdateByIdAPI(warehouseLayout:{}) {
    return Instance({
            url:WHl_BASE+ `update`,
            method: 'PUT',
            data:warehouseLayout
        }
    )
}

//获取第一层数据
export function useGetFirstLevelAPI() {
    return Instance({
            url:WHl_BASE+ `getFirstLevel`,
            method: 'GET',
        }
    )
}
//获取第二层数据
export function useGetSecondLevelAPI() {
    return Instance({
            url:WHl_BASE+ `getSecondLevel`,
            method: 'GET',
        }
    )
}

//获取第三层数据
export function useGetThirdLevelAPI() {
    return Instance({
            url:WHl_BASE+ `getThirdLevel`,
            method: 'GET',
        }
    )
}

//根据pid获取父节点数据
export function useGetParentByPidAPI(pid:number) {
    return Instance({
            url:WHl_BASE+ `getOneByPid`,
            method: 'GET',
            params:{
                pid
            }
        }
    )
}

//根据containerName删除一条数据
export function useDeleteByContainerNameAPI(containerName:string) {
    return Instance({
            url:WHl_BASE+ `deleteByContainerName`,
            method: 'DELETE',
            params:{
                containerName
            }
        }
    )
}

//获取数据条数
export function useGetCountsAPI() {
    return Instance({
            url:WHl_BASE+ `getAllCounts`,
            method: 'GET',
        }
    )
}